Skip to content

Conversation

@bouwew
Copy link
Contributor

@bouwew bouwew commented Nov 28, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Devices classified as certain grouped switch types no longer auto-create redundant sensor or switch entities; those devices are now intended to be managed via Home Assistant group helpers.
  • Tests
    • Updated test snapshots and registry expectations to match the reduced set of auto-created entities.
  • Chores
    • Bumped project version and updated changelog for the new release.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 28, 2025

Walkthrough

Skip creating sensor and switch entities for devices whose dev_class is "report" or "switching"; update tests/snapshots and version/metadata accordingly.

Changes

Cohort / File(s) Summary
Entity filtering logic
custom_components/plugwise/sensor.py, custom_components/plugwise/switch.py
Add guard checks to skip devices whose DEV_CLASS is in SWITCH_GROUPS (("report","switching")) during entity-creation loops; no other API changes.
Constants & metadata
custom_components/plugwise/const.py, custom_components/plugwise/manifest.json, pyproject.toml, CHANGELOG.md
Add SWITCH_GROUPS constant; bump manifest and project versions to v0.62.0 and update changelog entry.
Test snapshots
tests/components/plugwise/snapshots/test_switch.ambr, tests/components/plugwise/snapshots/test_sensor.ambr
Remove snapshot entries for the filtered-out switch and sensor entities (relay and Adam electricity_* snapshots).
Test assertions
tests/components/plugwise/test_init.py
Adjust expected entity/device registry counts downward to match removed entities (counts decreased by 3 in affected assertions).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect guard logic in sensor.py and switch.py to ensure DEV_CLASS matching against SWITCH_GROUPS is correct and robust.
  • Verify snapshots removed exactly match filtered entities and remaining snapshots remain valid.
  • Confirm updated assertions in test_init.py are consistent with the new filtering.

Possibly related PRs

Suggested labels

quality

Suggested reviewers

  • CoMPaTech

Poem

🐰 I hopped through code with a nimble spring,

Skipped "report" and "switching" — a tidy thing.
I pruned some snapshots, trimmed the test-filled bed,
Fewer entities now, and carrots in my head. 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: removing Plugwise switch-groups and using HA group-helper instead, which is directly supported by the code changes filtering out SWITCH_GROUPS devices.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch disable-switch-groups

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 174945c and 9c64fd2.

📒 Files selected for processing (1)
  • custom_components/plugwise/switch.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • custom_components/plugwise/switch.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Setup for HA-core (dev)
  • GitHub Check: Setup for HA-core (release/master)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
custom_components/plugwise/switch.py (1)

95-110: Switch-group blocking guard is correctly placed and safe

The added dev_class filter cleanly skips creating switch entities for "report"/"switching" devices, after verifying the device has switches, and safely handles missing dev_class via .get(). This matches the PR goal of blocking switch-groups in favor of HA’s group helper without impacting other devices.

custom_components/plugwise/sensor.py (1)

480-495: Sensor filtering matches switch behavior and aligns with intent

The new dev_class check uses the same "report"/"switching" filter as in switch.py, applied after confirming sensors are present. This keeps group/report devices from exposing sensors while leaving normal devices untouched, which fits the documented “block switch-groups, use HA group helper instead” intent.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 31525a6 and c4c7acc.

📒 Files selected for processing (4)
  • custom_components/plugwise/sensor.py (1 hunks)
  • custom_components/plugwise/switch.py (1 hunks)
  • tests/components/plugwise/snapshots/test_switch.ambr (0 hunks)
  • tests/components/plugwise/test_init.py (3 hunks)
💤 Files with no reviewable changes (1)
  • tests/components/plugwise/snapshots/test_switch.ambr
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: bouwew
Repo: plugwise/plugwise-beta PR: 671
File: custom_components/plugwise/switch.py:82-83
Timestamp: 2024-10-08T15:35:25.180Z
Learning: User bouwew prefers to ignore exception handling suggestions for the `pw-beta` branch in the `custom_components/plugwise/switch.py` file.
Learnt from: bouwew
Repo: plugwise/plugwise-beta PR: 671
File: custom_components/plugwise/switch.py:82-83
Timestamp: 2024-06-22T08:05:56.791Z
Learning: User bouwew prefers to ignore exception handling suggestions for the `pw-beta` branch in the `custom_components/plugwise/switch.py` file.
📚 Learning: 2024-09-27T09:48:30.890Z
Learnt from: bouwew
Repo: plugwise/plugwise-beta PR: 734
File: tests/components/plugwise/test_config_flow.py:58-58
Timestamp: 2024-09-27T09:48:30.890Z
Learning: In `tests/components/plugwise/test_config_flow.py`, the versions are mocked firmware versions for testing purposes and do not need to match the software version in `manifest.json`.

Applied to files:

  • tests/components/plugwise/test_init.py
📚 Learning: 2024-10-08T15:35:25.180Z
Learnt from: bouwew
Repo: plugwise/plugwise-beta PR: 671
File: custom_components/plugwise/switch.py:82-83
Timestamp: 2024-10-08T15:35:25.180Z
Learning: User bouwew prefers to ignore exception handling suggestions for the `pw-beta` branch in the `custom_components/plugwise/switch.py` file.

Applied to files:

  • custom_components/plugwise/switch.py
🧬 Code graph analysis (3)
tests/components/plugwise/test_init.py (1)
tests/components/plugwise/conftest.py (1)
  • mock_config_entry (81-95)
custom_components/plugwise/switch.py (1)
custom_components/plugwise/entity.py (1)
  • device (94-96)
custom_components/plugwise/sensor.py (1)
custom_components/plugwise/entity.py (1)
  • device (94-96)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Prepare and validate pre-commit
🔇 Additional comments (1)
tests/components/plugwise/test_init.py (1)

298-305: Entity/device count expectations correctly updated to match new filtering

The reduced entity (51→50, 58→57) and device (10→9, 11→10) counts in all three assertion blocks are consistent with skipping devices having dev_class "report" or "switching". The test still exercises the add/remove flow for the extra Tom/Floor device; this looks good and aligned with the integration changes.

Also applies to: 322-329, 349-356

Copy link
Member

@CoMPaTech CoMPaTech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

@bouwew bouwew force-pushed the disable-switch-groups branch from c4c7acc to 277169e Compare November 28, 2025 18:33
@bouwew bouwew changed the title Quick try blocking switch-groups Remove Plugwise switch-groups - use HA group-helper to create switch-groups instead Nov 28, 2025
@bouwew bouwew marked this pull request as ready for review November 28, 2025 18:46
@bouwew bouwew requested a review from a team as a code owner November 28, 2025 18:46
@sonarqubecloud
Copy link

@bouwew
Copy link
Contributor Author

bouwew commented Dec 1, 2025

Not a good solution, closing this attempt.

@bouwew bouwew closed this Dec 1, 2025
@bouwew bouwew deleted the disable-switch-groups branch December 5, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants